package com.nubia.service;

import com.nubia.dao.ShopsDao;
import com.nubia.entity.Shops;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class  ShopsServiceImpl implements ShopsService{
    @Autowired
    ShopsDao shopsDao;

    @Override
    public List<Shops> findAllShops() {
        return shopsDao.selectAllShops();
    }

    @Override
    public int addCart(Shops shops) {
        return shopsDao.updateCart(shops);
    }

    /**
     * 根据userid 获取shoplist
     * @return
     */
    @Override
    public List<Shops> ShowCart(String user_id) {
        return shopsDao.ByShopShowCart(user_id);
    }

    @Override
    public int addShop(Shops shops) {
        return shopsDao.insertShop(shops);
    }
    @Override
    public Shops ByIdGetShop(String shop_id) {
        return shopsDao.GetShopById(shop_id);
    }

    /**
     * 添加一条商品
     */
    @Override
    public int insShop(Shops shops) {
        return shopsDao.insertOneShop(shops);
    }
}
